<?php


namespace App\Http\Controllers\Admin;


use App\DTOS\Admin\MemberDTO;
use App\Http\Controllers\Controller;
use App\Services\Game\MemberService;
use App\Utils\ResponseUtil;

class MemberController extends Controller
{
    private MemberService $memberService;

    /**
     * MemberController constructor.
     * @param MemberService $memberService
     */
    public function __construct(MemberService $memberService)
    {
        $this->memberService = $memberService;
    }

    public function paginate()
    {
        $paginate = $this->memberService->paginate(new MemberDTO(request()->all()));
        $data = $paginate->items();
        foreach($data as &$datum){
            $datum['openid'] = (string)$datum['openid'];
        }
        $res = [];
        $res['code'] = 0;
        $res['count'] = $paginate->total();
        $res['data'] = $data;
        return ResponseUtil::json($res);
    }

}
